
"""

docker run -p 8080:8080 -p 1337:1337 -p 7900:7900 --shm-size="2g" hlohaus789/g4f:latest

curl -X POST -H "Content-Type: application/json" -d '{
"model": "gpt-3.5-turbo",
"stream": false,
"messages": [
{
    "role": "user",
    "content": "hello, are you GPT 4?"
}
]
}' http://localhost:1337/v1/chat/completions

"""

import json
from DrissionPage import WebPage

q = "请解答问题， 宽字节注入怎么判断列数？, 详情: 在burpsuite上使用如下没有返回结果。 name=kube%df’ order by 2#"
page = WebPage("s")
payload = {
        "model": "gpt-3.5-turbo",
        "stream": False,
        "messages": [{"role": "user", "content": q}],
    }
page.post(
    "http://192.168.113.134:1337/v1/chat/completions",
    data=json.dumps(payload),
    headers={"Content-Type": "application/json"}
)

print(page.json)
result = ''
for choice in page.json['choices']:
    result += choice['message']['content']

print(result)